/**
* @metaWorkspace: a #Meta.Workspace
*/
-function Workspace(metaWorkspace) {
- this._init(metaWorkspace);
+function Workspace(metaWorkspace, monitorIndex) {
+ this._init(metaWorkspace, monitorIndex);
}
Workspace.prototype = {
- _init : function(metaWorkspace) {
+ _init : function(metaWorkspace, monitorIndex) {
// When dragging a window, we use this slot for reserve space.
this._reservedSlot = null;
this.metaWorkspace = metaWorkspace;
this._width = 0;
this._height = 0;
+ this.monitorIndex = monitorIndex;
+ this._monitor = global.get_monitors()[this.monitorIndex];
this._windowOverlaysGroup = new Clutter.Group();
// Without this the drop area will be overlapped.
this._windowOverlaysGroup.set_size(0, 0);
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
- let windows = Main.getWindowActorsForWorkspace(this.metaWorkspace.index());
+ let windows = global.get_window_actors().filter(this._isMyWindow, this);
// Create clones for windows that should be
// visible in the Overview
Lang.bind(this, this._windowAdded));
this._windowRemovedId = this.metaWorkspace.connect('window-removed',
Lang.bind(this, this._windowRemoved));
+ this._windowEnteredMonitorId = global.screen.connect('window-entered-monitor',
+ Lang.bind(this, this._windowEnteredMonitor));
+ this._windowLeftMonitorId = global.screen.connect('window-left-monitor',
+ Lang.bind(this, this._windowLeftMonitor));
this._repositionWindowsId = 0;
this.leavingOverview = false;
this._windowOverlaysGroup.hide();
},
- _windowRemoved : function(metaWorkspace, metaWin) {
+ _doRemoveWindow : function(metaWin) {
let win = metaWin.get_compositor_private();
// find the position of the window in our list
if (index == -1)
return;
+ // Check if window still should be here
+ if (win && this._isMyWindow(win))
+ return;
+
let clone = this._windows[index];
this._windows.splice(index, 1);
Lang.bind(this, this._delayedWindowRepositioning));
},
- _windowAdded : function(metaWorkspace, metaWin) {
+ _doAddWindow : function(metaWin) {
if (this.leavingOverview)
return;
Mainloop.idle_add(Lang.bind(this,
function () {
if (this.actor && metaWin.get_compositor_private())
- this._windowAdded(metaWorkspace, metaWin);
+ this._doAddWindow(metaWin);
return false;
}));
return;
}
- if (!this._isOverviewWindow(win))
+ // We might have the window in our list already if it was on all workspaces and
+ // now was moved to this workspace
+ if (this._lookupIndex (metaWin) != -1)
+ return;
+
+ if (!this._isMyWindow(win) || !this._isOverviewWindow(win))
return;
let clone = this._addWindowClone(win);
this.positionWindows(WindowPositionFlags.ANIMATE);
},
+ _windowAdded : function(metaWorkspace, metaWin) {
+ this._doAddWindow(metaWin);
+ },
+
+ _windowRemoved : function(metaWorkspace, metaWin) {
+ this._doRemoveWindow(metaWin);
+ },
+
+ _windowEnteredMonitor : function(metaScreen, monitorIndex, metaWin) {
+ if (monitorIndex == this.monitorIndex) {
+ this._doAddWindow(metaWin);
+ }
+ },
+
+ _windowLeftMonitor : function(metaScreen, monitorIndex, metaWin) {
+ if (monitorIndex == this.monitorIndex) {
+ this._doRemoveWindow(metaWin);
+ }
+ },
+
// check for maximized windows on the workspace
hasMaximizedWindows: function() {
for (let i = 0; i < this._windows.length; i++) {
this.metaWorkspace.disconnect(this._windowAddedId);
this.metaWorkspace.disconnect(this._windowRemovedId);
+ global.screen.disconnect(this._windowEnteredMonitorId);
+ global.screen.disconnect(this._windowLeftMonitorId);
if (this._repositionWindowsId > 0)
Mainloop.source_remove(this._repositionWindowsId);
this.leavingOverview = false;
},
- // Tests if @win belongs to this workspaces
+ // Tests if @win belongs to this workspaces and monitor
_isMyWindow : function (win) {
- return Main.isWindowActorDisplayedOnWorkspace(win, this.metaWorkspace.index());
+ return Main.isWindowActorDisplayedOnWorkspace(win, this.metaWorkspace.index()) &&
+ (!win.get_meta_window() || win.get_meta_window().get_monitor() == this.monitorIndex);
},
// Tests if @win should be shown in the Overview
controls.connect('scroll-event',
Lang.bind(this, this._onScrollEvent));
+ this._monitorIndex = global.get_primary_monitor_index();
+ this._monitor = global.get_monitors()[this._monitorIndex];
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
controls.add_actor(this._thumbnailsBox.actor);
this._workspaces = [];
for (let i = 0; i < global.screen.n_workspaces; i++) {
let metaWorkspace = global.screen.get_workspace_by_index(i);
- this._workspaces[i] = new Workspace.Workspace(metaWorkspace);
+ this._workspaces[i] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
}
if (this.workspacesView)
// Assume workspaces are only added at the end
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
let metaWorkspace = global.screen.get_workspace_by_index(w);
- this._workspaces[w] = new Workspace.Workspace(metaWorkspace);
+ this._workspaces[w] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
}
this._thumbnailsBox.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);